define(function(require, exports, module) {
 
	/**
	 * 
	 * @param  {String} ids [description]
	 * @return {Object}     [description]
	 */
	function url2json(ids){
		var _json = {};
		if(ids && ids.indexOf("#") != -1){
			
			ids = ids.split('#');
			ids = ids.pop();
			ids = ids.replace(/&/g, '","').replace(/=/g, '":"');
			if(ids){
				_json = JSON.parse('{"' + ids +'"}');
			} 
			// var ids = ids.split('&');
			// var json = {};
			// for(var arr, i = 0, j = ids.length; i < j; i++){
			// 	arr = ids[i];
			// 	arr = arr.split('=');
			// 	json[arr[0]] = arr[1];
			// }
		}
		return _json;
	}

	function setUrl(key, value){
		var hash = window.location.hash;
		console.log(value)
		if(hash.indexOf(key) != -1){
			var reg = new RegExp(key + '=[\\w-]+');
			window.location.hash = hash.replace(reg, key + '=' + value);
		}else{
			// append
			if(!hash)
				window.location.hash = key + '=' + value;
			else{
				window.location.hash += '&' + key + '=' + value;
			}
		}
	}
	exports.set = setUrl;
});